﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Nanohope_v1._0
{
    class Scenery
    {
        List<Scene> scenes;
        public Vector2 worldSize;
        int sceneIndex;

        public Scenery()
        {
            LoadScenes();
            sceneIndex = scenes[0].id;
            //worldSize = scenes.Count * sceneSize;
        }

        private void LoadScenes()
        {
            scenes = new List<Scene>();
            //carregar cenas de arquivo
        }

        public void Update(GameTime gameTime)
        {
            /*
            if(character.position.X > sceneIndex * sceneSize + sceneSize)
            {
                sceneIndex++;
            }
            else if(character.position.X < sceneIndex * sceneSize)
            {
                sceneIndex--;
            }
            */

            if (sceneIndex < scenes.Count - 1 && sceneIndex > 0)
            {
                scenes[sceneIndex - 1].Update(gameTime);
                scenes[sceneIndex + 1].Update(gameTime);
            }
            else if (sceneIndex > 0)
            {
                scenes[sceneIndex - 1].Update(gameTime);
            }
            else
            {
                scenes[sceneIndex + 1].Update(gameTime);
            }
            scenes[sceneIndex].Update(gameTime);
        }

        public void onDraw(SpriteBatch spriteBatch)
        {
            if (sceneIndex < scenes.Count - 1 && sceneIndex > 0)
            {
                scenes[sceneIndex - 1].onDraw(spriteBatch);
                scenes[sceneIndex + 1].onDraw(spriteBatch);
            }
            else if (sceneIndex > 0)
            {
                scenes[sceneIndex - 1].onDraw(spriteBatch);
            }
            else
            {
                scenes[sceneIndex + 1].onDraw(spriteBatch);
            }
            scenes[sceneIndex].onDraw(spriteBatch);
        }
    }
}
